<?php
class Controller_Test_JChat extends Controller
{
    public function __construct ($request, $response)
    {
        parent::__construct($request, $response);
    }

    public function action_init ()
    {
        $query = DB::select('uid')
            ->from('user_v2')
            ->where('userJChatId', 'is', NULL)
            ->execute();

        foreach ($query as $rs)
        {
            $uid  = $rs['uid'];
            $user = User::getUserFromUid($uid);  
            $user->updateUserPushId(1);
        }
    }

    public function action_register ($uid)
    {
        $jchat = new JChat;
        $result = $jchat->register(array($uid));
        print_r($result);
    }

    public function action_update ($uid)
    {
        $user  = User::getUserFromUid($uid);
        $nickname = $user->getUserName();
        $gender   = $user->getUserGender();
        $gender   = 'f';

        $jchat = new JChat;
        $result = $jchat->setUserInfo($uid, $nickname, $gender);
        print_r($result);
    }

    public function action_info ($uid)
    {
        $jchat = new JChat;
        $result = $jchat->getUserInfo($uid);
        print_r($result);
    }

    public function action_avatar ($uid)
    {
        $jchat = new JChat;
        $result = $jchat->setUserAvatar($uid);
        print_r($result);
    }
}
